package com.maya.service;

import java.util.List;

import org.bson.types.ObjectId;
import org.mongodb.morphia.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.maya.dao.LogDAO;
import com.maya.model.Log;


@Service
public class LogService {
	
	@Autowired
	private LogDAO ldao;
	
	public void save(Log log){
		
		ldao.save(log);
	}
	
	public List<Log> getByOwnerId(ObjectId id) {
		
		Query<Log> query = ldao.createQuery().field("ownerId").equal(id).order("-happenedAt");
        List<Log> logs = query.asList();
        return logs;
	}

}
